const mongoose = require('mongoose')
const { Schema, model } = mongoose
const commentSchema = new Schema(
  {
    __v: { type: Number, select: false },
    content: { type: String, required: true },
    commentator: {
      type: Schema.Types.ObjectId,
      ref: 'User',
      required: true,
      select: false
    },
    questionId: { type: String, required: true },
    answerId: { type: String, required: true },
    // 一级评论id，非必选
    rootCommentId: { type: String },
    // 回复给谁，非必选
    replyTo: { type: Schema.Types.ObjectId, ref: 'User' }
  },
  { timestamps: true }
)
module.exports = model('Comment', commentSchema)
